import { ConfigProvider, theme, Switch } from 'antd';
import { useState } from 'react';
import Routes from './routes';

function App() {
  //全局状态控制白天黑夜的切换
  const [isDark, setIsDark] = useState(false);

  return (
    <ConfigProvider
      theme={{
        algorithm: isDark ? theme.darkAlgorithm : theme.defaultAlgorithm
      }}
    >
      <div style={{ padding: '10px' }}>
        <Switch
          checked={isDark}
          onChange={() => setIsDark(!isDark)}
          checkedChildren="🌙"
          unCheckedChildren="☀️"
        />
        <Routes />
      </div>
    </ConfigProvider>
  );
}

export default App;
